<?php
declare (strict_types = 1);
namespace app\promotion\service;

use think\facade\Request;
use app\common\service\BaseService;
use app\common\exception\LogicException;
use app\promotion\logic\PromotionBargain;


/**
 * 砍价接口处理类
 */
class Bargain extends BaseService
{
	
	/**
	 * 获取当前用户指定课程砍价详情
	 * Author 亓官雨树<lucky.max@foxmail.com>
	 * Date 2021-04-09
	 * @return [type] [description]
	 */
	public function getSponsorBargainInfo()
	{
		$promotion_id = Request::get('promotion_id/d');
		
        // 验证数据
        if (!$promotion_id)  throw new LogicException("参数错误");

		$data = app(PromotionBargain::class)->getSponsorBargainInfo($promotion_id);

		return $this->parseToData($data, 1, '获取成功');
	}

	/**
	 * 砍价
	 * Author 亓官雨树<lucky.max@foxmail.com>
	 * Date 2021-04-12
	 * @return [type] [description]
	 */
	public function doBargain()
	{
		$param = Request::post();
		
		$data = app(PromotionBargain::class)->doBargain($param);

		return $this->parseToData($data, 1, '砍价成功');
	}
}